<%-content_for :javascript_include do-%>
  <%= javascript_include_tag "jquery.Jcrop" %>
  <%= javascript_include_tag "image_crop" %>
  <%=stylesheet_link_tag "jquery.Jcrop.css"%>
<%-end-%>
<script type="text/javascript">
  $().ready(function() {
    $("#new_user_image").validate({
      rules: {
        "user_image[uploaded_data]": {
          required: true
        }
      },
      messages:{
        "user_image[uploaded_data]": {
          required: "请选择要上传的文件."
        }
      },
      errorPlacement: function(error,element){
        error.appendTo(element.next());
      }
    });
  });
</script>
<div class="content">
  <div class="sub_nav clearfix">
    <ul>
      <li><%=link_to '编辑用户信息', edit_profile_user_path(@current_user) %></li>
      <li  class="selected_tab"><%=link_to '更新头像', edit_image_user_path(@current_user)%></li>
    </ul>
  </div>
  <%unless flash.now[:notice].nil?%>
    <div id="message_box" style="display:block;">
      <div class="r_message"><%=flash.now[:notice]%></div>
    </div>
  <%end%>
  <div class="user_image">
    <table border="0" width="70%">
      <tr>
        <td class="big_image" valign="top">
          <%=user_image_tag @current_user,"big"%>
        </td>
        <td  valign="top" style="padding:0px 10px;">
          <span  style="">头像预览:</span>
          <div style="width:60px;height:60px;overflow:hidden;margin-top:6px;">
            <%=user_image_tag @current_user,"small"%>
          </div>
        </td>
        <td valign="top" style="padding-left:50px;">
          <%form_for @user_image ,:url => update_image_user_path(@current_user),:html => {:class => "user_image_upload_form",:multipart=>true,:autocomplete=>'off' } do |f|%>
            <span class="note_text">你可以上传jpg,jpeg,gif,png 等格式的图片(小于2M)</span>
            <p>
              <%=f.file_field  :uploaded_data ,:class=>"input_file",:size=>"30", :style=>"padding:5px;font-size:1.2em;"%>
              <span></span>
            </p>
            <p>
              <%=submit_tag "更新头像",:class=>"submit"%>
            </p>
          <%end%>
          <p style="display:block;clear:both;">小头像图标(点击下面的保存可以生成自定义的头像)</p>
          <div style="width:60px;height:60px;overflow:hidden;margin-top:10px;">
            <%=user_image_tag @current_user,"small"%>
          </div>
        </td>
      </tr>
    </table>
    <%form_tag update_image_user_path(@current_user) do%>
      <p class="p_submit">
        <%=hidden_field_tag 'imgpos'%>
        <%=submit_tag "保存",:class=>"submit"%>
      </p>
    <%end%>
  </div>
</div>
